package com.yipinhouse.signing.app.appImpl;

import cn.hutool.core.bean.BeanUtil;
import com.yipinhouse.common.result.Result;
import com.yipinhouse.signing.client.ContractQueryClient;
import com.yipinhouse.signing.client.SigningQueryClient;
import com.yipinhouse.signing.client.result.ContractResult;
import com.yipinhouse.signing.client.result.HouseTradeResult;
import com.yipinhouse.signing.service.ContractService;
import com.yipinhouse.signing.service.SigningService;
import com.yipinhouse.signing.service.dto.ContractDto;
import com.yipinhouse.signing.service.dto.HouseTradeDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/signing")
public class ContractQueryApiImpl implements ContractQueryClient {
    @Resource
    private ContractService service;

    @Override
    public Result<List<ContractResult>> getContractByUser(Integer userId) {
        log.info("获取用户合同信息:参数：{}",userId);
        List<ContractDto> dots = service.getContractByUser(userId);
        List<ContractResult> results = BeanUtil.copyToList(dots, ContractResult.class);
        return Result.getInstanceList(ContractResult.class).setMsg("获取用户合同信息成功！").setData(results);
    }
}
